<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="java.util.Collection"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	List<TblCheckDevice> list = (List<TblCheckDevice>)request.getAttribute("list");
	SettingForm form = (SettingForm)request.getAttribute("command");
%>
<div class="main">
	<div class="oaTable">
<table class="tableList">

	<thead>
		<tr>
			<td colspan="10" style="width: 100%;">
				<div class="FormTools">
					<div>
						<input type="button" class="searchSubmit" onclick="javascript:XF.Setting.listDeviceSearch()" value="搜索"/>
					</div>
					<div>序列号：
						<input id="sn" type="text" name="sn" class="search" value="<%=StringUtils.isNotBlank(form.getSn())?form.getSn():""%>"
							placeholder="请输入序列号"/>
					</div>
					<div>
						状态：
						<select id="status" name="status">
							<option value="-1"></option>
							<option value="1">离线</option>
							<option value="0">在线</option>
						</select>
					</div>

				</div>
			</td>
		</tr>
	</thead>

	<tbody>
		<tr id="tableHeader">
			<th style="width: 20%">设备名称</th>
			<th style="width: 20%">序列号</th>
			<th style="width: 20%">站点</th>
			<th style="width: 20%">更新时间</th>
			<th style="width: 10%">状态</th>
			<th style="width: 10%">操作</th>
		</tr>
		<%
			if (list != null && list.size() > 0) {
				for (TblCheckDevice device: list) {
					String id = EncrypTool.encode(device.getId()+"");

		%>
						<tr>
							<td><%=device.getName()!=null?device.getName():"" %></td>
							<td><%=device.getSn()!=null?device.getSn():"" %></td>
							<td><%=device.getSitename()!=null?device.getSitename():"" %></td>
							<td><%=device.getUpdatetime()!=null?DateFormatUtils.format(device.getUpdatetime(), "yyyy-MM-dd HH:mm:ss"):"" %></td>
							<td><%=device.getStatus() %></td>
							<td>
								<div class="innerBtnWrap">
									<a class="a-btn-microsoft btn topBtn" href="javascript:XF.Setting.deleteDevice('<%=id %>')">删除</a>
								</div>
							</td>							
						</tr>
					<%
				}
			}
		
		%>
		        
        		<tr id="tableFooter">
			<td colspan="10">
				<div class="pagination">
					<monggoTag:pagination href="device_search"
						pageSize="<%=form.getPageSize()%>"
						totalRecord="<%=form.getTotalRecord() %>"
						currentPage="<%=form.getPageNum() %>">
					</monggoTag:pagination>
				</div>
			</td>
		</tr>
	</tbody>
</table>
</div>
</div>
<script>
	$("#status").find("option[value='<%=form.getStatus() %>']").attr("selected",true);
</script>
